package com.it.common.utils

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide

import com.bumptech.glide.request.RequestOptions
import java.io.File


object GlideUtils {
    fun loadNet(
        context: Context,
        url: String,
        imageView: ImageView,
        defaultRes: Int? = null,
        errorRes: Int? = null
    ) {
        val options = RequestOptions();
        if (defaultRes != null) {
            options.placeholder(defaultRes) // 设
        }
        if (errorRes != null) {
            options.error(errorRes) // 设
        }
        Glide.with(context)
            .load(url)
            .apply(options) // 应用 RequestOptions
            .into(imageView)
    }

    fun loadRes(
        context: Context,
        res: Int,
        imageView: ImageView,

        ) {
        Glide.with(context)
            .load(res)
            .into(imageView)
    }

    fun loadFile(
        context: Context,
        path: String,
        imageView: ImageView,

        ) {
        Glide.with(context)
            .load(File(path))
            .into(imageView)
    }
}